<?php
namespace app\admin\validate;

use think\Validate;

class Config extends Validate
{
    protected $rule = [
        'name'    =>  'require|max:100|unique:config',
        'name_cn' =>  'require|max:100|unique:config',
        'option'  =>  'max:500',
        'value'   =>  'require|max:200',
        'type'    =>  'require|in:0,1,2',
    ];
    
    protected $message  =   [
        'name.require' => '配置项英文名称不允许为空',
        'name.max'     => '配置项英文名称最多不能超过60字符',
        'name.unique'  => '配置项英文名称不允许重复',
        'name_cn.require' => '配置项中文名称不允许为空',
        'name_cn.max'  => '配置项中文名称最多不能超过60字符',
        'name_cn.unique'  => '配置项中文名称不允许重复',
        'option.max'  => '配置项可选值不允许超过500个字符',
        'value.require' => '配置项当前值不允许为空',
        'value.max' => '配置项当前值最大长度为100字符',
        'type.require' => '配置项类型不能为空',
        'type.in' => '配置项类型必须为单选值单行文本或者多行文本',   
    ];
    
    protected $scene = [
        'edit' => ['name'=>'require|max:60','name_cn' =>'require|max:60','option' =>'max:500','value' =>'require|max:100','type' => 'require|in:0,1,2'],
    ];
}
